package com.jxtti.utils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.jxtti.model.User;

public class AuthUtil {

	public static Integer getUserId(HttpServletRequest request) {
		HttpSession session = request.getSession();
		User userInfo = (User) session.getAttribute("userInfo");
		return userInfo.getId();
	}

	public static User getUserInfo(HttpServletRequest request) {
		HttpSession session = request.getSession();
		return (User) session.getAttribute("userInfo");
	}
	
	public static void setUser(HttpServletRequest request, User user) {
		HttpSession session = request.getSession();
		//session.setAttribute("cssPath", Constants.CSS_PATH);
		session.setAttribute("uploadPath", Constants.YINGSHE_PATH);
		session.setAttribute("userInfo", user);
	}

}
